package com.mc.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mc.model.Department;
import com.mc.model.Path;
import com.mc.model.ResearchLab;
import com.mc.model.Teacher;
import com.mc.service.IDepartmentService;
import com.mc.service.IResearchLabService;
import com.mc.service.TeacherService;
import com.mc.utils.PathUtil;

@Controller
@RequestMapping("/academygk")
public class AcademyIntro {
      private Path path = null;
      @Autowired private IDepartmentService departmentService;
      @Autowired private TeacherService teacherService;
      @Autowired private IResearchLabService labService;
      /**
       * 
       * @param modelMap
       * @return  返回学院简介的页面
       */
	@RequestMapping("/academyintro")
	public String AcademyIntro1(ModelMap modelMap)
	{
		path = PathUtil.setPathParams(new String[]{"PackageName:AcademyGK","ViewName:xueyuanjianjie","ViewTitle:学院简介","smenu:AcademyGK","mmenu:AcademyIntro"});				
		return PathUtil.returnStr(path, modelMap);
	}
	/**
	 * 
	 * @param modelMap
	 * @return 返回组织结构的页面
	 */
	@RequestMapping("/orgjg")
	public String OrgJGui(ModelMap modelMap)
	{
		List<ResearchLab> labs = labService.selectAllResearchLab();
		modelMap.addAttribute("labs",labs);
		List<Department> jxjgs = departmentService.selectbydtype("教学机构 ");
		List<Department> dzjgs = departmentService.selectbydtype("党政机构");
		modelMap.addAttribute("jxjgs", jxjgs);
		modelMap.addAttribute("dzjgs", dzjgs);
		path = PathUtil.setPathParams(new String[]{"PackageName:AcademyGK","ViewName:zuzhijigou","ViewTitle:组织机构","smenu:AcademyGK","mmenu:OrgJG"});				
		return PathUtil.returnStr(path, modelMap);
	}
	/**
	 * 
	 * @param modelMap
	 * @param id  属于组织机构的某个部门id  需要展示本门的主任、副主任、成员、简介
	 * @return  返回展示部门信息的页面
	 */
	@RequestMapping("/zdetail/{id}")
	public String zdetail(ModelMap modelMap,@PathVariable("id")int id){
		Department department = departmentService.selectByPrimaryKey(id);
		List<Teacher> ld1 = teacherService.selectbypositionadid(id, "主任");
		List<Teacher> ld2 = teacherService.selectbypositionadid(id, "副主任");
		List<Teacher> teachers = teacherService.selectbydid(id);
		modelMap.addAttribute("ld1", ld1);
		modelMap.addAttribute("ld2", ld2);
		modelMap.addAttribute("teachers", teachers);
		modelMap.addAttribute("department", department);
		path = PathUtil.setPathParams(new String[]{"PackageName:AcademyGK","ViewName:detail","ViewTitle:组织机构----"+department.getdName(),"smenu:AcademyGK","mmenu:other","mmmenu:other"});				
		return PathUtil.returnStr(path, modelMap);
	}
}
